<template>
<div class="zctu">
  <el-form
    :model="form"
    status-icon
    :rules="rules"
    ref="form"
    label-width="100px"
    class="demo-ruleForm"
  >
    <el-card class="box-card">
      <h1>注册</h1>
      <el-form-item label="账号"  class="k1" prop="t_number">
        <el-input v-model="form.t_number" placeholder="请输入账号"></el-input>
      </el-form-item>
      <el-form-item label="密码"  class="k2" prop="password">
        <el-input v-model="form.password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="doInsert('form')" class="an"
          >完成</el-button
        >
      </el-form-item>
    </el-card>
  </el-form>
  </div>
</template>

<script>
const axios = require("axios");
export default {
  name:"zc",
  data() {
    return {
      form: {
        t_number: "",
        password: "",
      },
      rules: {
        t_number: [{ required: true, message: "请输入账号", trigger: "blur" }],
        password: [{ required: true, message: "请输入密码",trigger: "blur" }],
      },
    };
  },
  methods: {
    doInsert(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let _this = this;
          axios
            .post(
              "https://localhost:44386/api/login/createteachers",_this.form
            )
            .then(function (response) {
              
              if (response.data >= 1) {
                _this.$notify({
                  title: "成功",
                  message: "注册成功",
                  type: "success",
                });
                _this.form.t_number="";
                _this.form.password="";
                _this.$router.push({ name: "jsdl" });
                // debugger
              }
              else {
                _this.$notify({
                  title: "警告",
                  message: "注册异常",
                  type: "warning",
                });
              }
            });
        } else {
          return false;
        }
      });
    },
    // form(formName) {
    //   this.$refs[formName].resetFields();
    // },
  },
};
</script>

<style scoped>
.k2 {
  width: 400px;
}
.k1 {
  width: 400px;
  margin-bottom: 50px;
}
.zctu{
    background-image: url("4.jpg");
  width: 100%;
  height: 100%;
  background-size: cover;
  position: absolute;
  z-index: -1;
  background-repeat: no-repeat;
}
h1 {
  color:#fff;
  letter-spacing: 30px;
  margin-left: 180px;
}
.an {
  margin-left: 100px;
}
.box-card {
  width: 500px;
  height: 350px;
  border-radius: 20px;
  margin: 0px auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(61, 124, 160, 0.822);
}
</style>